package com.drool.mediaplayer.Adapters;

import com.drool.mediaplayer.R;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore.Audio;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class GalleryAlbumAdapter extends CursorAdapter{

	private int cursorPosition;
	
	public GalleryAlbumAdapter(Context context, Cursor c, int cursorPos) {
		super(context, c);
		
		cursorPosition = cursorPos;		
		//c.moveToPosition(cursorPos);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		// TODO Auto-generated method stub
		ImageView albumArt = (ImageView)view.findViewById(R.id.albumArt4);
		TextView albumName = (TextView)view.findViewById(R.id.albumName4);
		//ListView songList = (ListView)view.findViewById(R.id.songList4);
		
		Uri audio = Audio.Media.EXTERNAL_CONTENT_URI;
		
		//cursor.moveToPosition(cursorPosition);
		
		if (cursor.getString(1) != null){
			albumArt.setImageURI(Uri.parse(cursor.getString(1)));
		}
		else
			albumArt.setImageResource(R.drawable.musicdelta);
		albumName.setText(cursor.getString(2));
			
	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = LayoutInflater.from(context);
		View v = inflater.inflate(R.layout.laygalleryitem, parent, false);
		bindView(v, context, cursor);
		return v;
	}

}
